
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>三鑫灯世界 - 提交订单</title>
    <style type="text/css">
        .xuan{border: 1px solid #013ca6 !important;}
        #bg{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.7; opacity:.70; filter: alpha(opacity=70);}
        #show{display: none; position: absolute; top: 200px; left: 22%; width: 53%; height: 40%; padding: 8px; border: 8px solid #E8E9F7; background-color: white; z-index:1002; overflow: auto;}
        #fitTabletop{display: none;position: absolute; top: 152px; left: 22%;width: 53%;padding: 8px;border: 8px solid #013ca6; z-index:1005;text-align: right;color: #fff;font-size: 20px;background: #013ca6;;}
        .loading{display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: #fff; z-index:1002; -moz-opacity: 0.6; opacity:.60; filter: alpha(opacity=60);}
        .loading img{position: absolute !important;    top: 0;    right: 0;    bottom: 0;    left: 0;    margin: auto; }
        .hui{color: #666}
        .order-address h2 {
            margin-bottom: 15px;
        }

        .order-confirmOrder h2 {
            line-height: 25px;
            color: #333;
            font-weight: 700;
            font-size: 14px;
        }
        .order-address .list, .order-address .moreAddr {
            width: 1004px;
        }
        .order-address .addr {
            display: inline-block;
            vertical-align: top;
            position: relative;
            width: 237px;
            margin: 0 14px 14px 0;
            color: #666;
            cursor: pointer;
        }
        .order-address .addr .inner {
            z-index: 2;
            position: relative;
            padding: 13px 15px;
            background: url(__PUBLIC__/img/bian2.png) no-repeat;
            overflow: hidden;
        }
        .order-address .addr-active .inner, .order-address .addr-cur .inner {
            background-image: url(__PUBLIC__/img/bian1.png);
        }
        .order-address .addr .addr-hd {
            width: 100%;
            border-bottom: 1px solid #f2f2f2;
            padding: 0 0 5px;
            margin-bottom: 5px;
            line-height: 18px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .order-address .addr .addr-hd span {
            display: inline-block;
            vertical-align: top;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .order-address .addr {
            display: inline-block;
            vertical-align: top;
            position: relative;
            width: 237px;
            margin: 0 14px 14px 0;
            color: #666;
            cursor: pointer;
        }
        #App {
            min-height: 400px;
            padding-bottom: 60px;
            width: 990px;
            margin: auto;
            color: #666;
        }
        .order-address .addr .city {
            font-weight: 700;
            max-width: 64px;
            margin-right: 10px;
        }

        .order-address .addr .addr-bd {
            height: 36px;
            overflow: hidden;
            word-break: break-all;
            word-wrap: break-word;
        }
        .order-address .addr-cur .addr-bd {
            height: 36px;
        }
        .page a {
            color: #c97;
            cursor: pointer;
        }

        a {
            text-decoration: none;
        }
        .order-address .addr-cur .curMarker {
            visibility: visible !important;
        }
        .order-address .addr .curMarker {
            z-index: 3;
            position: absolute;
            background-position: 0 -272px!important;
            width: 28px;
            height: 28px;
            top: 77px;
            right: 0px;
            visibility: hidden;
        }
        .order-address .addr .curMarker {
            background: url(__PUBLIC__/img/tiaomaomao.png) no-repeat;
        }
        .order-address .option {
            height: 33px;
            width: 225px;
            overflow: hidden;
            position: absolute;
            top: 73px;
            left: 6px;
            border: 1px solid #EBEBEB;
            border-top: 0;
            border-bottom: 0;
            border-radius: 0 0 2px 2px;
            background: url(__PUBLIC__/img/T1zRuMXA0aXXb5sY6b-227-7.png) 50% 100% no-repeat;
            z-index: 1;
        }
        .electrician{
            width: 100px;
            height: 60px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-top: 10px;
            text-align: center;
            float: left;
            margin-right: 20px;
            cursor:pointer;
        }
        .xuanred{border: 1px solid red;}
    </style>

    <script src="__PUBLIC__/hytn/js/jquery-1.9.1.min.js"></script>
    <script src="__PUBLIC__/layer/layer.js"></script>
    <script src="__PUBLIC__/hytn/js/jquery.form.min.js" type="text/javascript"></script>
    <script src="__PUBLIC__/shop.js"></script>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/submodal.css" />
    <script type="text/javascript" src="__PUBLIC__/js/submodalsource.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/css/c.css">
    <link rel="stylesheet" href="__PUBLIC__/css/page.css">
</head>
<body>
<!--如果$count为空，则表示非购物车页面请求-->
<if condition="$count eq null">
    <script>
        window.location.href="{:U('shop_order')}"
    </script>
</if>
<!--公共头部2-->
<include file="Public:head2"/>

<div class="main-wrap" style="width: 1372px;margin: 0 auto;">
    <div class="setting">
        <form id="form1" action="{:U('Pay/pay')}" method="post" autocomplete="off" novalidate="novalidate">
            <div class="main-t">
                <div class="order-address " id="address_1">
                    <h2>选择收货地址</h2>
                    <div class="list">
                        <foreach name="addressList" item="v">
                            <div class="addr suggest-address addr-def <if condition="$v.status eq 1">addr-cur</if>">
                            <input type="hidden" class="address_id" name="address_id" value="{$v.address_id}">
                            <div class="inner">
                                <div class="zongaddress">
                                    <div class="addr-hd">
                                        <span class="prov" >{$v.province_name}</span>
                                        <span class="prov" >{$v.city_name}</span>
                                        <span class="city" >{$v.county_name}</span>
                                        <span >（</span>
                                        <span class="name">{$v.receiver}</span>
                                        <span > 收）</span>
                                    </div>
                                    <div class="addr-bd" >
                                        <span class="dist" >{$v.town_name}</span>
                                        <span class="street" >{$v.detailed_address}</span>
                                        <span class="phone" style="display:inline;">{$v.phone}</span>
                                        <span class="last" >&nbsp;</span>
                                    </div>
                                </div>
                                <div class="addr-toolbar" style="display: inline-block" >
                                    <if condition="$v['status'] eq 1">
                                        <a class="modify ajax-form" id="edit" href="javascript:;">修改</a>
                                        <else />
                                        <a class="modify ajax-form ajax-delete red" id="del" data-info="确定删除？" href="javascript:;" >删除</a>
                                    </if>
                                </div>
                                <div class="curMarker"></div>
                            </div>
                    </div>
                    </foreach>
                </div>
            </div>
            <div class="table-wrap chks-table">
                <table>
                    <thead>
                    <tr class="">
                        <th class="tl" width="160">客户名称</th>
                        <th class="tl" width="840">收货信息</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="receive_tr" id="receive_tr_9837143">
                        <td class="tl">
                            <span>{:session('user_name')}</span>
                        </td>
                        <td class="tl">
                            <span>收货人：</span>
                            <span class="xianame">{$default_address['receiver']}</span>
                            <span>联系电话：</span>
                            <span class="xiaphone">{$default_address['phone']} </span>
                            <span class="xiaaddress">{$default_address['province_name']}{$default_address['city_name']}{$default_address['county_name']}{$default_address['town_name']}{$default_address['detailed_address']}</span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>





            <div class="control-box ui-page-tab-con order" style="margin-top:20px">
                <div class="grid-wrap">
                    <div class="ui-jqgrid ui-widget ui-widget-content ui-corner-all" id="gbox_grid" dir="ltr" style="width: 100%;">
                        <div class="ui-jqgrid-view" role="grid" id="gview_grid" style="width: 100%;">
                            <div class="ui-jqgrid-titlebar ui-jqgrid-caption ui-widget-header ui-corner-top ui-helper-clearfix" style="display: none;">
                                <a role="link" class="ui-jqgrid-titlebar-close ui-corner-all HeaderButton" title="Toggle Expand Collapse Grid" style="right: 0px;">
                                    <span class="ui-icon ui-icon-circle-triangle-n"></span>
                                </a><span class="ui-jqgrid-title"></span>
                            </div>
                            <div class="ui-state-default ui-jqgrid-hdiv ui-corner-top" style="width: 100%;"><div class="ui-jqgrid-hbox">
                                <table class="ui-jqgrid-htable" style="width: 100%;" role="presentation" aria-labelledby="gbox_grid" cellspacing="0" cellpadding="0" border="0">
                                    <thead style="width: 100%;">
                                    <tr class="ui-jqgrid-labels" role="row" style="width: 100%;">
                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">商品</div>
                                        </th>

                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">商品名称</div>
                                        </th>

                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">商品规格</div>
                                        </th>
                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">数量</div>
                                        </th>
                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">市场价</div>
                                        </th>
                                        <if condition="session('user_vip') eq 1">
                                            <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                                <div id="jqgh_grid_name" class="ui-jqgrid-sortable">会员价</div>
                                            </th>
                                        </if>

                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">运费</div>
                                        </th>

                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr install_price" style="width: 10%;display:none;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">安装费</div>
                                        </th>

                                        <th id="grid_name" role="columnheader" class="ui-state-default ui-th-column ui-th-ltr" style="width: 10%;">
                                            <div id="jqgh_grid_name" class="ui-jqgrid-sortable">小计（不含安装费）</div>
                                        </th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                            </div>
                            <div class="ui-jqgrid-bdiv" style="height: auto; width: 100%;">
                                <div style="position:relative;">
                                    <table id="grid" tabindex="0" cellspacing="0" cellpadding="0" border="0" role="presentation" aria-multiselectable="false" aria-labelledby="gbox_grid" class="ui-jqgrid-btable" style="width: 100%;text-align:center;border-collapse:collapse">
                                        <tbody>
                                        <volist name="list" id="li">
                                            <tr class="ui-widget-content  ui-row-ltr" style="height:104px;width: 100%;border-bottom: 1px solid #d6dee3;">
                                                <td role="gridcell" style="text-align:center;"><img src="__ROOT__{$li.picture}" style="width:100px;height:100px;"></td>
                                                <td role="gridcell" style="text-align:center;">{$li.good_name}</td>
                                                <td role="gridcell" style="text-align:center;">{$li.grade}</td>
                                                <td role="gridcell" style="text-align:center;">{$li.goods_num}</td>
                                                <td role="gridcell" style="text-align:center;">￥{$li.price}</td>
                                                <if condition="session('user_vip') eq 1">
                                                    <td role="gridcell" style="text-align:center;">￥{$li['vip_price']}</td>
                                                </if>
                                                <!-- 增加单一商品安装费隐藏域 -->
                                                <input type="hidden" name="install_price_{$li.good_id}" value="{$li.install_price}">
                                                <td role="gridcell" style="text-align:center;color:red;"><b>包邮</b></td>
                                                <td role="gridcell" class="install_price" style="text-align:center;display:none;">￥{$li.install_price}</td>
                                                <td role="gridcell" style="text-align:center;"><if condition="session('user_vip') eq 1">￥{$li['goods_num']*$li[vip_price]}<else />￥{$li['goods_num']*$li[price]}</if></td>
                                            </tr>
                                        </volist>

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>



                <div class="order-total" style="background:#F5F6F7;min-height: 40px;">
                    <input type="hidden" name="dealer_price" value="0"><!--经销商价格-->
                    <input type="hidden" name="market_price" value="0"><!--市场价格-->
                    <div class="total-r" style="width: 700px;">
                        <div class="total-group">
                            <div style="width: 60%;float: left;">
                                <label class="total-label total-rel-money-label" style="width: 240px;font-size: 14px;">
                                    <span style="font-weight: bold;">是否需要安装</span>(<span style="color: red">安装费：￥<span id="install_price">
										<if condition="($install_price gt $configInfo['min_install_price']) and (session('user_vip') eq 0)">
											{$install_price}
										<elseif condition="($vip_install_price gt $configInfo['min_install_price']) and (session('user_vip') eq 1)" />
											{$vip_install_price}
										<else />
											{$configInfo['min_install_price']}
										</if></span>)：
                                </label>
                                <input type="checkbox" name="is_install" id="an" value="1" />
                            </div>
                            <div style="width: 40%;float: left;">
                                <label class="total-label total-rel-money-label" style="width: 140px !important;">总计：	</label>
                                <!-- 商品总价格隐藏域 -->
                                <input type="hidden" name="count" id="count" value="{$count}">
                                <div class="total red" style="text-align: left;color: red !important;font-size: 20px;">￥<span class="total-rel-money">{$count}</span></div>
                            </div>
                        </div>
                    </div>
                </div>

                <div style="margin-top: 20px;display: none;" id="zongelectrician">
                    <span style="font-size: 15px;"><b>附近电工</b></span>（选择乡镇并选中电工可实现就近安装，且享受<span style="color:red;"><b>{$configInfo['nearby_install_rebate']*100 | rtrim=###,0}折</b></span>优惠，否则默认系统抢单）：
                    <select name="code" id="town" onchange="town_electrician()">
                        <option value="">请选择乡/镇</option>
                        <volist name="town_list" id="vo">
                            <option value="{$vo.code}">{$vo.name}</option>
                        </volist>
                    </select>
                    <div id="electrician">

                    </div>
                </div>


                <div style="clear: both;"></div>

                <div style="margin-top: 20px;font-size: 14px;">
                    <p>安装费收取标准：</p>
                    <p>1）射灯、开关等类似小型部件，按个收取</p>
                    <p>2）除小型部件的其余商品，按其总价的 <b style="color: red;">{$configInfo['install_price_rebate']*100}%</b> 收取</p>
                    <p>3）所有商品的安装费总额未满<b style="color: red;"> {$configInfo['min_install_price']} </b>元，按<b style="color: red;"> {$configInfo['min_install_price']} </b>元收取</p>
                </div>
            </div>
    </div>

    <div class="func clearfix" style="margin-top: 20px;">
        <div id="zhifu"><span style="font-size: 14px;vertical-align: text-top;margin-right: 20px;">选择支付方式 > ></span>
            <button type="button" class="ui-btn addAddress" data-pay="alipay" style="padding: 0;">
                <span class="ui-btn-txt xuan" style="border: 1px solid #f5f5f5;padding: 2px 4px;background:#f5f5f5;"><img src="__PUBLIC__/img/alipay_logo.png" alt="" width="22px" style="float: left;margin-top: 5px;"><div style="float: left;margin-left: 5px;padding-bottom: 20px;">支付宝支付</div><img src="__PUBLIC__/img/recommend_pay_logo.png" alt="" width="50px" style="margin-left: 5px;margin-top: 5px;"></span>
            </button>

            <button type="button" class="ui-btn addAddress " data-pay="wxpay" style="margin-left: 20px;padding: 0;">
                <span class="ui-btn-txt" style="border: 1px solid #f5f5f5;padding: 2px 4px;background:#f5f5f5;"><img src="__PUBLIC__/img/wechat_pay_logo.png" alt="" width="25px" style="float: left;margin-top: 5px;"><div style="margin-left: 5px;float: left;">微信支付</div></span>
            </button>
        </div>
    </div>

    <div class="control-box btn-submit saveBox">
        <div class="saveBg"></div>
        <input type="hidden" name="cid" value="{$cid}">
        <button class="ui-btn ui-btn-theme save">去支付</button>
    </div>
    <input type="hidden" name="diangongid" id="diangongid" value="" />
    </form>

</div>

</div>
</div>

<div id="bg" onclick="hidediv();"></div>
<p id="fitTabletop" onclick="hidediv();">关闭</p>
<div id="show">
    <form action="{:U('add_edit_address')}" method="post" class="ajax-form">
        <div class="alert-content">
            <div class="addressManage pt30 pb30">
                <div class="address-edit-con control-box" style="">
                    <input type="hidden" name="type" value="1">
                    <input type="hidden" id="address_id" name="address_id" value="">
                    <div class="control-group">
                        <div class="control-label"><a style="color:red;">*</a>&nbsp;收货地址</div>
                        <div class="control-input selCity">
                            <select  name="province" id="province" style="width:106px;margin-right:10px;" onchange="citys()" required>
                                <option value="" >请选择省份</option>
                                <volist name="province_list" id="v">
                                    <option value="{$v.code}" >{$v.name}</option>
                                </volist>
                            </select>

                            <select  name="city" id="city" style="width:106px;margin-right:10px;" onchange="countys()" required>
                                <option value="" >请选择城市</option>
                            </select>

                            <select  name="county" id="county" style="width:106px;margin-right:10px;" onchange="villages()" required>
                                <option value="" >请选择县区</option>
                            </select>

                            <select  name="town" id="towns" style="width:106px;margin-right:10px;" required>
                                <option value="" >请选择乡镇</option>
                            </select>

                            <script type="text/javascript">
                                addressInit('Select1', 'Select2', 'Select3');
                            </script>
                        </div>
                    </div>

                    <div class="control-group">
                        <div class="control-label"><a style="color:red;">*</a>&nbsp;详细地址</div>
                        <div class="control-input">
                            <input type="text" class="ui-input" id="address" name="detailed_address" autocomplete="off" required>
                        </div>
                    </div>

                    <div class="control-group control-group-line">
                        <div class="control-label"><a style="color:red;">*</a>收货人</div>
                        <div class="control-input">
                            <input type="text" class="ui-input" id="receiver" name="receiver" autocomplete="off" required>
                        </div>

                        <div class="control-label control-label-2"><a style="color:red;">*</a>&nbsp;电话</div>
                        <div class="control-input">
                            <input type="text" class="ui-input" id="phone" name="phone" autocomplete="off" required>
                        </div>
                    </div>

                    <div class="control-group control-group-line">
                        <div class="control-label">邮编</div>
                        <div class="control-input">
                            <input type="text" class="ui-input" id="zip_code" name="postcode" autocomplete="off">
                        </div>

                        <div class="control-label control-label-2">传真</div>
                        <div class="control-input">
                            <input type="text" class="ui-input" id="fax" name="fax" autocomplete="off">
                        </div>
                    </div>

                    <div class="control-group" style="text-align:center;">
                        <div class="control-label"></div>
                        <div class="control-input">
                            <button class="ui-btn ui-btn-theme" type="submit">保存</button>
                        </div>
                    </div>

                    <input type="hidden" name="addressId" value="0" autocomplete="off">
                </div>
            </div>
        </div>
    </form>
</div>
<div class="loading"><img src="__PUBLIC__/img/loading.gif" alt="正在加载..."></div>
<input type="hidden" name="moneyzong" id="moneyzong" value="{$count}" />
<!--公共底部-->
<include file="Public:footer"/>

<!-- 联系客服 -->
<a target="_blank" style="position: fixed;right: 20px;bottom: 65px;" href="http://wpa.qq.com/msgrd?v=3&uin=2675162351&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:2675162351:51" alt="联系客服" title="联系客服"/></a>
<a target="_blank" style="position: fixed;right: 20px;bottom: 35px;" href="http://wpa.qq.com/msgrd?v=3&uin=1478709334&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:2675162351:51" alt="联系客服" title="联系客服"/></a>
<script>
    //		$('.loading').show();
    $('.modify').click(function(){
        var aa = $(this);
        var address_id = $(this).parents('.addr').find('input').val();
        if($(this).attr('data-info')){
            $.ajax({
                url:"{:U('del_address')}",
                type:'post',
                data:{address_id:address_id},
                success:function(data){
                    if(data == 1){
                        aa.parent().parent().parent().remove();
                    }
                }
            });
        }else{
            $('.loading').show();
            $.ajax({
                url:"{:U('address_info')}",
                type:'post',
                data:{address_id:address_id},
                success:function(data){
                    var data = JSON.parse(data);
                    $('#province option').each(function (){
                        if($(this).val() == data.province){
                            $(this).attr('selected','selected');
                        }
                    });

                    citys();
                    $('#city option').each(function (){
                        if($(this).val() == data.city){
                            $(this).attr('selected','selected');
                        }
                    });

                    countys();
                    $('#county option').each(function (){
                        if($(this).val() == data.county){
                            $(this).attr('selected','selected');
                        }
                    });

                    villages();
                    $('#towns option').each(function (){
                        if($(this).val() == data.town){
                            $(this).attr('selected','selected');
                        }
                    });
                    $('#address').val(data.detailed_address);
                    $('#receiver').val(data.receiver);
                    $('#zip_code').val(data.postcode);
                    $('#phone').val(data.phone);
                    $('#fax').val(data.fax);
                    $('#address_id').val(data.address_id);
                    //展示弹框
                    $('.loading').hide()
                    document.getElementById("bg").style.display ="block";
                    document.getElementById("show").style.display ="block";
                    document.getElementById("fitTabletop").style.display ="block";
                }
            });
        }
        return false;
    });

    function showdiv() {
        $("body").height($(window).height()).css({"overflow-y": "hidden"});
        $("#bg").attr("onclick","showdiv()");
        document.getElementById("bg").style.display ="block";
        document.getElementById("show").style.display ="block";
        document.getElementById("fitTabletop").style.display ="block";
    }
    function hidediv() {
        $("body").height($(window).height()).css({"overflow": "auto"});
        document.getElementById("bg").style.display ='none';
        document.getElementById("show").style.display ='none';
        document.getElementById("fitTabletop").style.display ="none";
    }

    $('#zhifu button').click(function(){
        $(this).find('span').addClass('xuan');
        $(this).siblings().find('span').removeClass('xuan');
        var pay_type = $(this).attr('data-pay');
        if(pay_type == 'wxpay'){
            $('#form1').attr('action',"{:U('Pay/wechat')}");
        }else{
            $('#form1').attr('action',"{:U('Pay/pay')}");
        }
    });

    //获取所有的城市
    function citys(){
        //获取被选中的option标签
        var province = $('#province option:selected').val();
        //ajax获取专题下的一级分类
        $.ajax({
            url:"{:U('city')}",
            type:'post',
            async: false,
            data:{province:province},
            success:function(data){
                var city = JSON.parse(data);
                var aa = '<option value="" >请选择城市</option>';
                for(var i=0;i<city.length;i++){
                    aa += '<option value="'+city[i].code+'">'+city[i].name+'</option>';
                }
                $('#city').html(aa);
            }
        })
    }

    //获取所有的县区
    function countys(){
        //获取被选中的option标签
        var city = $('#city option:selected').val();
        //ajax获取专题下的一级分类
        $.ajax({
            url:"{:U('county')}",
            type:'post',
            async: false,
            data:{city:city},
            success:function(data){
                var county = JSON.parse(data);
                var aa = '<option value="" >请选择县区</option>';
                for(var i=0;i<county.length;i++){
                    aa += '<option value="'+county[i].code+'">'+county[i].name+'</option>';
                    $('#county').html(aa);
                }
            }
        })
    }

    //获取所有的县区
    function villages(){
        //获取被选中的option标签
        var county = $('#county option:selected').val();
        //ajax获取专题下的一级分类
        $.ajax({
            url:"{:U('town')}",
            type:'post',
            async: false,
            data:{county:county},
            success:function(data){
                var county = JSON.parse(data);
                var aa = '<option value="" >请选择乡镇</option>';
                for(var i=0;i<county.length;i++){
                    aa += '<option value="'+county[i].code+'">'+county[i].name+'</option>';
                    $('#towns').html(aa);
                }
            }
        })
    }

    $(".inner").click(function(event){
        $(this).parent().addClass('addr-cur').siblings().removeClass('addr-cur');
        $('.xianame').text($(this).find('.name').text())
        $('.xiaphone').text($(this).find('.phone').text())
        $('.xiaaddress').text($(this).find('.prov').text()+$(this).find('.city').text()+$(this).find('.dist').text()+$(this).find('.town').text()+$(this).find('.street').text())
        $(this).find('a').text('修改');
        $(this).parent().siblings().find('a').text('删除');
        $(this).find('a').removeClass('red ajax-delete');
        $(this).parent().siblings().find('a').addClass('red ajax-delete');
        $(this).find('a').removeAttr('data-info','确认删除？');
        $(this).parent().siblings().find('a').attr('data-info','确认删除？');
        //获取选中的收货地址，进行数据库的修改
        var address_id = $(this).parents('.addr').find('input').val();
        $.ajax({
            url:"{:U('save_default_address')}",
            type:'post',
            data:{address_id:address_id},
            success:function(data){
                if(data != 1){
                   alert('设置默认地址失败');
                }
            }
        });

        event.stopPropagation();
    });

    //获取所在乡镇电工
    function town_electrician(){
        $('.loading').show();
        //获取被选中的option标签
        var town = $('#town option:selected').val();
        //ajax获取专题下的一级分类
        $.ajax({
            url:"{:U('town_electrician_list')}",
            type:'post',
            async: false,
            data:{town:town},
            success:function(data){
                $('.loading').hide();
                var electrician_list = JSON.parse(data);
                if(electrician_list.length == 0){
                    alert('该乡镇暂无电工注册');
                }
                $('#diangongid').val('');
                $('.total-rel-money').removeAttr('data-money')
                $('.total-rel-money').text(parseFloat("{$count}")+parseFloat($('#install_price').text()));
                $('#count').val($('.total-rel-money').text());
                var aa = '';
                for(var i=0;i<electrician_list.length;i++){
                    aa += '<div class="electrician" data-value="'+electrician_list[i].electrician_id+'">'
                            +'<div style="margin-top: 8px;"><span>'+electrician_list[i].real_name+'</span></div>'
                            +'<div><span>'+electrician_list[i].phone+'</span></div>'
                            +'<div style="color:#013ca6">点击选中/取消</div>'
                            +'</div>'
                }
                $('#electrician').html(aa);
            }
        })
    }
</script>
<if condition="$addressList eq null">
    <script>
        $(function () {
            showdiv();
            document.getElementById("fitTabletop").style.display ="none";
            $("#bg").removeAttr("onclick");
            window.name = "bencalie";//防止再次刷新
        })
    </script>
    <else />
    <!-- 强制刷新 -->
    <script>
        //后退强制刷新
        if(window.name != "bencalie"){
            location.reload();
            window.name = "bencalie";
        }else{
            window.name = "";
        }
    </script>
</if>

<script>
    /**
     * 除法函数，用来得到精确的除法结果 说明：javascript的除法结果会有误差，在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
     * 调用：accDiv(arg1,arg2) 返回值：arg1除以arg2的精确结果
     */
    function accDiv(arg1,arg2){
        var t1=0,t2=0,r1,r2;
        try{t1=arg1.toString().split(".")[1].length}
        catch(e){}
        try{t2=arg2.toString().split(".")[1].length}
        catch(e){}
        with(Math){
            r1=Number(arg1.toString().replace(".",""));
            r2=Number(arg2.toString().replace(".",""));
            return (r1/r2)*pow(10,t2-t1);
        }
    }


    /**
     * javascript的乘法结果会有误差，在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
     *
     *
     */
    function accMul(arg1,arg2){
        var m=0,s1=arg1.toString(),s2=arg2.toString();
        try{m+=s1.split(".")[1].length}catch(e){}
        try{m+=s2.split(".")[1].length}catch(e){}
        return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
    }


    $('#an').click(function () {
        if($(this).is(':checked')){
            $("#zongelectrician").css('display','block');
            $('.install_price').css('display','table-cell');
            $('.total-rel-money').text(parseFloat(parseFloat($('#install_price').text())+parseFloat($('.total-rel-money').text())).toFixed(2));
            //隐藏域总额相应变化
            $('#count').val(parseFloat(parseFloat($('#install_price').text())+parseFloat($('#count').val())).toFixed(2));
        }else{
            $('#electrician>div').removeClass('xuanred');
            $('.total-rel-money').removeAttr('data-money');
            $("#zongelectrician").css('display','none');
            $('.install_price').css('display','none');
//      $('.total-rel-money').text(parseFloat(parseFloat($('.total-rel-money').text())-parseFloat($('#install_price').text())).toFixed(2));
            $('.total-rel-money').text("{$count}");
            //隐藏域总额相应变化
//      $('#count').val(parseFloat(parseFloat(parseFloat($('#count').val())-$('#install_price').text())).toFixed(2));
            $('#count').val("{$count}");
            $('#diangongid').val("");
        }
    })

    $(document).on('click','#electrician>div',function(){

        if($(this).is('.xuanred')){
            $(this).removeClass('xuanred');
            $('.total-rel-money').removeAttr('data-money');
            $('.total-rel-money').text(accDiv(parseFloat($('.total-rel-money').text()),{$configInfo['nearby_install_rebate']}));
            $('#count').val($('.total-rel-money').text());
            $('#diangongid').val("")
        }else{
            $(this).addClass('xuanred').siblings().removeClass('xuanred');
//		$('.total-rel-money').text(parseFloat(parseFloat($('.total-rel-money').text()*0.95,10)).toFixed(2))
//		$('.total-rel-money').text(accMul(parseFloat($('.total-rel-money').text()),0.95)
            if(!$('.total-rel-money').attr('data-money')){
                $('.total-rel-money').text(accMul(parseFloat($('.total-rel-money').text()),{$configInfo['nearby_install_rebate']}));
                $('#count').val($('.total-rel-money').text());
                $('.total-rel-money').attr('data-money','1')
            }
            $('#diangongid').val($(this).attr('data-value'))
        }

    })

</script>
</body>
</html>